<!--#include file="../Include/Conn.asp" -->
<!--#include file="../Include/Inc.Asp" -->
<!--#include file="../Include/Function.asp"-->
<!--#include file="seeion.asp"-->
<%call chkAdmin("|4")%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" id="css" href="images/style.css">
<style>
#picdiv{width:100%;position:relative;overflow:hidden}
.box{width:220px;height:290px;float:left;margin:5px;padding:6px;background:#FFF;border:1px #EBEBEB solid}
.box a.tbox{width:220px;height:240px;display:block;position:relative;overflow:hidden;}
.box a.tbox img{width:220px;height:240px;}
.box a.tbox p{width:220px;position:absolute;display:block;background:black;text-align:center;color:#FFFFFF;
filter:alpha(opacity:60);opacity:0.6;height:25px;margin:0;bottom:0;z-index:1}
.on{padding:5px;border:2px #F00 solid}
body,td,th {font-family: "Microsoft YaHei", Arial, "宋体";}
</style>
<body>
<%Set FSO = CreateObject("scripting.filesystemobject") 
dirPath = Server.MapPath("\"&zych_template&"\") 
tempdir="\"&zych_template&"\"
if right(dirPath,1)<>"/" then dirPath=dirPath&"\" 
If FoundErr = True Then
	reserr ErrMsg,0
End If%>
<%if request.querystring("action")="admin" then%>
<table width="100%" border="0" cellspacing="0" cellpadding="0"  class="stable" style="border:1px #399 solid; margin-bottom:10px">
  <tr>
    <td height="30" class="topnav"><div>PC模版列表</div></td>
  </tr>
  <tr>
    <td style="padding:5px">
<div id="picdiv">
<%On Error Resume Next 
Set f = FSO.GetFolder(dirPath) 
Set fsubfolers = f.SubFolders
For Each dir in fsubfolers 
 dirdn = dir.name
if instr(dirdn,"P_")>0 then
if zych_tempdir=dirdn then css=" on" else css=""
if zych_tempdir=dirdn then style=" style=""background:#060""" else style=""
if zych_tempdir=dirdn then txt="正在使用" else txt="设为当前"%>
<div class="box <%=css%>">
  <form name="form1" action="" method="post">
    <a href="javascript:void(0)" class="tbox"><img src="<%=tempdir%><%=dirdn%>/pic.jpg" width="160" height="170" />
    <p><%=dirdn%></p></a>
    <div style="text-align:center;padding-top:10px">
      <input name="tempdir" type="hidden" id="tempdir" value="<%=dirdn%>"/>
      <input name="Submit" type="submit" class="button" value="<%=txt%>" onClick="if(confirm('确定要设置为当前!')){form.action='?action=admin&tempsz=ok';}else{return false};" <%=style%>/>
      <input type="submit" class="button" value="模板列表"  onClick="javascript:this.form.action='?action=list';">
      <input class="btn" type="submit" value="删除模板" onClick="if(confirm('确定要删除吗，删除后无法恢复')){form.action='?action=admin&tempdel=ok';}else{return false};"/>  
    </div>
  </form>
</div>
<%end if
Next
Set FSO = Nothing%>
</div></td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0"  class="stable" style="border:1px #399 solid; margin-bottom:10px">
  <tr>
    <td height="30" class="topnav"><div>移动站模版列表</div></td>
  </tr>
  <tr>
    <td style="padding:5px">
<div id="picdiv">
<%On Error Resume Next 
Set f = FSO.GetFolder(dirPath) 
Set fsubfolers = f.SubFolders
For Each dir in fsubfolers 
dirdn = dir.name
if instr(dirdn,"m_")>0 then
if zych_tempmdir=dirdn then css=" on" else css=""
if zych_tempmdir=dirdn then style=" style=""background:#060""" else style=""
if zych_tempmdir=dirdn then txt="正在使用" else txt="设为当前"
%>
<div class="box <%=css%>">
  <form name="form1" action="" method="post">
    <a href="javascript:void(0)" class="tbox"><img src="<%=tempdir%><%=dirdn%>/pic.jpg" width="160" height="170" />
    <p><%=dirdn%></p></a>
    <div style="text-align:center;padding-top:10px">
      <input name="tempdir" type="hidden" id="tempdir" value="<%=dirdn%>"/>
      <input name="Submit" type="submit" class="button" value="<%=txt%>" onClick="if(confirm('确定要设置为当前!')){form.action='?action=admin&mtempsz=ok';}else{return false};" <%=style%>/>
      <input type="submit" class="button" value="模板列表"  onClick="javascript:this.form.action='?action=list';">
      <input class="btn" type="submit" value="删除模板" onClick="if(confirm('确定要删除吗，删除后无法恢复')){form.action='?action=admin&tempdel=ok';}else{return false};"/>  
    </div>
  </form>
</div>
<%end if
Next
Set FSO = Nothing%>
 </div></td>
  </tr>
</table>
<%End if%>

<%if request.querystring("action")="list" then
nowtemp=request.form("tempdir")%>
<form action="" method="post" name="myform">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="stable" style="border:1px #399 solid; margin-bottom:10px">
    <tr>
      <td colspan="3" height="30" class="topnav"><div>模板列表<%= nowtemp %></div></td>
    </tr>
    <%Set f = FSO.GetFolder(dirPath&nowtemp) 
Set fsubfolers = f.Files
	For Each dir in fsubfolers 
	dn = dir.name
	tbody=ReadFromTextFile("\"&zych_template&"\"&nowtemp&"\"&dn&"","utf-8")
	if instr(tbody,"<!--##")>0 then title=split(tbody,"##")(1) else title=""
	%>
    <tr>
      <td width="238" align="right" class="l"><%=title%></td>
      <td width="1354" class="l"><a href="?action=edit&nowtemp=<%=nowtemp%>&tempname=<%=dn%>"><%=dn%></a></td>
      <td width="198"><a href="?action=edit&nowtemp=<%=nowtemp%>&tempname=<%=dn%>">编辑</a> | <a href="?filedel=ok&nowtemp=<%=nowtemp%>&tempname=<%=dn%>" onClick="return confirm('提示\n\n您确定要删除当前模板吗！')">删除</a></td>
    </tr>
    <%Next%>
  </table>
</form>
<%End if
if request.querystring("action")="edit" then
if key<>0 and instr(manage,"|5")=0 then
	Call adminJump("Sorry!","您没有管理该模块的权限！","javascript:window.history.go(-1)")
	response.End
End if
nowtemp = Request.QueryString("nowtemp")
tempname = Request.QueryString("tempname")
fileurl = "/"&zych_template&"/"&nowtemp&"/"&tempname
Text_Content=ReadFromTextFile(FileUrl,"utf-8")%>
<form action="" method="post" name="myform">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="stable" style="border:1px #399 solid; margin-bottom:10px">
  <tr>
    <td colspan="2" height="30" class="topnav"><div>模板修改<%=fileurl%></div></td>
  </tr>
  <tr>
   <td><textarea name="text_content" style="width:100%;background:#2b2b2b;color:#ac8053;padding:5px;" rows="30" wrap="OFF"  id="text_content"><%=Server.HTMLEncode(Text_Content)%></textarea></td>
  </tr>
  <tr><input name="temppath" type="hidden" value="<%=fileurl%>"/><input name="tempdir" type="hidden" value="<%=nowtemp%>"/><input name="tempname" type="hidden" value="<%=tempname%>"/>
    <td><input name="提交" type="submit" value="修改模板" class="button" onClick="javascript:this.form.action='?modify=ok';"/> <input type="submit" class="button" value="模板列表"  onClick="javascript:this.form.action='?action=list';">我们建议您尽量使用Dreamweaber等软件编辑好后FTP上传，不要使用浏览器来进行编辑。</td>
  </tr>
</table>
</form>
<%

End if%>
</body>
</html>
<%
'设置PC版模板
if Request.QueryString("tempsz")="ok" then
tempdir=Request.Form("tempdir")
if tempdir="" then
Response.Write "<script>alert('错误!请选择要操作的记录!');history.go(-1);</script>" 
response.end()
end if
sql="update [config] set tempdir='"&tempdir&"' where id=1" 
conn.execute(sql) 
Response.Write "<script>alert('设置为当前模板成功!');window.location.href='admin_template.asp?action=admin';</script>" 
end if
'设置手机版模板
if Request.QueryString("mtempsz")="ok" then
tempdir=Request.Form("tempdir")
if tempmdir="" then
Response.Write "<script>alert('错误!请选择要操作的记录!');history.go(-1);</script>" 
response.end()
end if
sql="update [config] set tempmdir='"&tempdir&"' where id=1" 
conn.execute(sql) 
Response.Write "<script>alert('设置为当前手机站模板成功!');window.location.href='admin_template.asp?action=admin';</script>" 
end if

if Request.QueryString("modify")="ok" then
	temppath=Request.Form("temppath")
	tempdir=Request.Form("tempdir")
	tempname=Request.Form("tempname")
	If temppath= "" Then echo "超作错误,模版路径错误!"
	Text_Content = Request.Form("Text_Content")
	call WriteToTextFile (temppath,Text_Content,"utf-8")
	Response.Write "<script>alert('恭喜您修改模版成功!');window.location.href='admin_template.asp?action=edit&nowtemp="&tempdir&"&tempname="&tempname&"';</script>" 
End if
'删除模板
if Request.QueryString("tempdel")="ok" then
if key<>0 and instr(manage,"|5")=0 then
	Call adminJump("Sorry!","您没有管理该模块的权限！","javascript:window.history.go(-1)")
	response.End
End if
	tempdir= Request.Form("tempdir")
    fileurl="/"&zych_template&"/"&tempdir&""
    file_delete(fileurl)
	Response.Write "<script>alert('"&tempdir&"模板删除成功!');window.location.href='admin_template.asp?action=admin';</script>" 
End if
'删除模板文件
if Request.QueryString("filedel")="ok" then
if key<>0 and instr(manage,"|5")=0 then
	Call adminJump("Sorry!","您没有管理该模块的权限！","javascript:window.history.go(-1)")
	response.End
End if
	nowtemp=Request.QueryString("nowtemp")
	tempname=Request.QueryString("tempname")
    fileurl="/"&zych_template&"/"&nowtemp&"/"&tempname
    file_delete(fileurl)
	Response.Write "<script>alert('删除成功!');window.location.href='admin_template.asp?action=admin';</script>" 
End if
%>
